package com.mapull.primitive;

/**
 * @author Mapull
 * @date 2024-04-21
 */
public class SimpleFloat {
    public static void main(String[] args) {
        float maxValue = Float.NaN;
        boolean b1 = Float.isNaN(maxValue);
        Float f1 = Float.valueOf(Float.POSITIVE_INFINITY);
        boolean b2 = f1.isNaN();
        System.out.println("Float.NaN isNaN " + b1);
        System.out.println("Float.POSITIVE_INFINITY isNaN " + b2);
    }
    public static void main18(String[] args) {
        float maxValue = Float.MAX_VALUE;
        boolean b1 = Float.isInfinite(maxValue);
        Float f1 = Float.valueOf(Float.POSITIVE_INFINITY);
        boolean b2 = f1.isInfinite();
        System.out.println("Float.MAX_VALUE isInfinite " + b1);
        System.out.println("Float.POSITIVE_INFINITY isInfinite " + b2);
    }
    public static void main17(String[] args) {
        Float f1 = Float.valueOf("12.001f");
        Float f2 = Float.valueOf("12.001F");
        Float f3 = Float.valueOf("-12.99F");
        boolean bool = f1.equals(f2);
        System.out.println(bool);
        System.out.println(f2.equals(f3));
    }

    public static void main16(String[] args) {
        int i1 = Float.compare(12.001f, 12.001f);
        int i2 = Float.compare(12.001f, 886f);
        System.out.println(i1);
        System.out.println(i2);
    }

    public static void main15(String[] args) {
        Float f1 = Float.valueOf("12.001f");
        Float f2 = Float.valueOf("12.001F");
        Float f3 = Float.valueOf("-12.99F");
        Float f4 = Float.valueOf("886F");
        int i1 = f1.compareTo(f2);
        int i2 = f1.compareTo(f3);
        int i3 = f1.compareTo(f4);
        System.out.println(i1);
        System.out.println(i2);
        System.out.println(i3);
    }
    public static void main14(String[] args) {
        Float f1 = Float.valueOf("Nan"); //java.lang.NumberFormatException: For input string: "Nan"
        Float f2 = Float.valueOf("infinity");//java.lang.NumberFormatException: For input string: "infinity"
    }

    public static void main13(String[] args) {
        String str1 = Float.toString(123.001f);
        String str2 = Float.toString(-99.999f);
        String str3 = Float.toString(Float.MAX_VALUE);
        String str4 = Float.toString(Float.NaN);
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
        System.out.println(str4);
    }
    public static void main12(String[] args) {
        Float f1 = Float.valueOf("123.001");
        Float f2 = Float.valueOf("-1.99F");
        Float f3 = Float.valueOf(Float.MAX_VALUE);
        Float f4 = Float.valueOf(Float.NaN);
        String str1 = f1.toString();
        String str2 = f2.toString();
        String str3 = f3.toString();
        String str4 = f4.toString();
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
        System.out.println(str4);
    }

    public static void main11(String[] args) {
        String str1 = Float.toHexString(20f);
        String str2 = Float.toHexString(1.23F);
        String str3 = Float.toHexString(-2.3f);
        String str4 = Float.toHexString(0.0f);
        String str5 = Float.toHexString(Float.NaN);
        String str6 = Float.toHexString(Float.MAX_VALUE);
        String str7 = Float.toHexString(Float.POSITIVE_INFINITY);
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
        System.out.println(str4);
        System.out.println(str5);
        System.out.println(str6);
        System.out.println(str7);
    }

    public static void main10(String[] args) {
        float f1 = Float.parseFloat("Nan");//java.lang.NumberFormatException: For input string: "Nan"
        float f2 = Float.parseFloat("1B");//java.lang.NumberFormatException: For input string: "1B"
        float f3 = Float.parseFloat("MAX");//java.lang.NumberFormatException: For input string: "MAX"
        float f4 = Float.parseFloat("0x12.3");//java.lang.NumberFormatException: For input string: "0x12.3"
    }

    public static void main9(String[] args) {
        float f1 = Float.parseFloat("123.456");
        float f2 = Float.parseFloat("+36.009F");
        float f3 = Float.parseFloat("-.86");
        float f4 = Float.parseFloat("56.7D");
        float f5 = Float.parseFloat("NaN");
        System.out.println(f1);
        System.out.println(f2);
        System.out.println(f3);
        System.out.println(f4);
        System.out.println(f5);
    }

    public static void main8(String[] args) {
        Float f1 = Float.valueOf("123.001");
        Float f2 = Float.valueOf("-1.99F");
        Float f3 = Float.valueOf(Float.MAX_VALUE);
        Float f4 = Float.valueOf(Float.NaN);
        short b1 = f1.shortValue();
        short b2 = f2.shortValue();
        short b3 = f3.shortValue();
        short b4 = f4.shortValue();
        System.out.println(f1 + " short value " + b1);
        System.out.println(f2 + " short value " + b2);
        System.out.println(f3 + " short value " + b3);
        System.out.println(f4 + " short value " + b4);
    }
    public static void main7(String[] args) {
        Float f1 = Float.valueOf("123.001");
        Float f2 = Float.valueOf("-1.99F");
        Float f3 = Float.valueOf(Float.MAX_VALUE);
        double b1 = f1.doubleValue();
        double b2 = f2.doubleValue();
        double b3 = f3.doubleValue();
        System.out.println(f1 + " double value " + b1);
        System.out.println(f2 + " double value " + b2);
        System.out.println(f3 + " double value " + b3);
    }

    public static void main6(String[] args) {
        Float f1 = Float.valueOf("-1.99F");
        Float f2 = Float.valueOf("10086");
        Float f3 = Float.valueOf(Float.NEGATIVE_INFINITY);
        byte b1 = f1.byteValue();
        byte b2 = f2.byteValue();
        byte b3 = f3.byteValue();
        System.out.println(f1 + " byte value " + b1);
        System.out.println(f2 + " byte value " + b2);
        System.out.println(f3 + " byte value " + b3);
    }
    public static void main5(String[] args) {
        int size = Float.SIZE;
        int exponent = Float.MIN_EXPONENT;
        float minValue = Float.MIN_VALUE;
        float minNormal = Float.MIN_NORMAL;
        float maxValue = Float.MAX_VALUE;
        float naN = Float.NaN;
        int maxExponent = Float.MAX_EXPONENT;
        Class<Float> type = Float.TYPE;
        float infinity = Float.POSITIVE_INFINITY;
        float negInfinity = Float.NEGATIVE_INFINITY;
        System.out.println("Float.SIZE           " + size);
        System.out.println("Float.MIN_EXPONENT   " + exponent);
        System.out.println("Float.MIN_VALUE      " + minValue);
        System.out.println("Float.MIN_NORMAL     " + minNormal);
        System.out.println("Float.MAX_VALUE      " + maxValue);
        System.out.println("Float.NaN            " + naN);
        System.out.println("Float.TYPE           " + type);
        System.out.println("Float.MAX_EXPONENT   " + maxExponent);
        System.out.println("Float.POSITIVE_INFINITY " + infinity);
        System.out.println("Float.NEGATIVE_INFINITY " + negInfinity);
    }

    public static void main4(String[] args) {
        Float f1 = Float.valueOf("NaN");
        Float f2 = Float.valueOf("Infinity");
        System.out.println(f1);
        System.out.println(f2);
    }
    public static void main3(String[] args) {
        Float f1 = Float.valueOf("-1.99F");
        Float f2 = Float.valueOf("9.960000");
        Float f3 = Float.valueOf("3.75D");
        Float f4 = Float.valueOf(".618f");
        System.out.println(f1);
        System.out.println(f2);
        System.out.println(f3);
        System.out.println(f4);
    }

    public static void main2(String[] args) {
        Float f1 = Float.valueOf(-1.99f);
        Float f2 = Float.valueOf(9.960000f);
        Float f3 = Float.valueOf(3.75F);
        Float f4 = Float.valueOf(.618F);
        System.out.println(f1);
        System.out.println(f2);
        System.out.println(f3);
        System.out.println(f4);
    }

    public static void main1(String[] args) {
        Float f1 = new Float(3.1415);
        Float f2 = new Float("3.14");
        Float f3 = new Float(Double.NaN);
    }
}
